package com.duing.service.impl;

import com.duing.dao.DataMapper;
import com.duing.dao.GraphdataMapper;
import com.duing.entity.Graphdata;
import com.duing.entity.IllnessData;
import com.duing.service.DataService;
import com.duing.util.GsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DataServiceImpl implements DataService {

    @Autowired
    private DataMapper dataMapper;

    @Autowired
    private GraphdataMapper graphdataMapper;

    @Override
    public List<IllnessData> getList() {
        return dataMapper.getList();
    }

    @Override
    public List<Graphdata> getGraphDatas() {
        return graphdataMapper.selectAll();
    }


    public void initData() {
        dataMapper.deleteAll();
        List<IllnessData> list = GsonUtil.handleData();
        for (IllnessData illnessData : list) {
            dataMapper.insert(illnessData);
        }
    }
}
